package mas.patternVisualization;

import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;

import done.DBConnection;

public class PatternVisualization {
	
	public ArrayList timePs;
	public ArrayList valuesPs;
	public ArrayList timeWs;
	public ArrayList valuesWs;
	
	public Double getPresenceS()
	{
		Double max = new Double(0);
		DBConnection.initConnection();
		DBConnection.readyInserts();
		
		String query = "SELECT regDate,value FROM simulationdata_ WHERE sensor_id='Presence Sensor#3' ORDER BY regDAte DESC LIMIT 0 , 30";
		ResultSet rs = DBConnection.selectData(query);
		
		//getting information
		try {
			timePs = new ArrayList();
			valuesPs = new ArrayList();
			
			while (rs.next())
			{
				timePs.add(rs.getString("regDate"));
				if (rs.getDouble("value") > max)
				{
					max = rs.getDouble("value");
				}
				valuesPs.add(rs.getDouble("value"));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return max;
	}
	
	public Double getWaterS()
	{
		Double max = new Double(0);
		DBConnection.initConnection();
		DBConnection.readyInserts();
		
		String query = "SELECT regDate,value FROM simulationdata_ WHERE sensor_id='Water Sensor#1' ORDER BY regDAte DESC LIMIT 0 , 30";
		ResultSet rs = DBConnection.selectData(query);
		
		//getting information
		try {
			timeWs = new ArrayList();
			valuesWs = new ArrayList();
			
			while (rs.next())
			{
				timeWs.add(rs.getString("regDate"));
				if (rs.getDouble("value") > max)
				{
					max = rs.getDouble("value");
				}
				valuesWs.add(rs.getDouble("value"));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return max;
	}
}
